import edu.colorado.cs.{Project, Server}

class MyProject extends Project {
  override def init_data() = {
    data += (1.0 -> None)
    data += (2.0 -> None)
    data += (3.0 -> None)
  }

  override def split_data(): Option[Double] = {
    data.find(_._2 match {
      case None => true
      case Some(d: Double) => false
    }) match {
      case None => None
      case Some(d: (Double, Option[Double])) => Some(d._1)
    }
  }

  override def recombine_data() = {
    data foreach ((t) => println(t._1 + " -> " + t._2))
  }

  override def add_result(in: Double, out: Double) = {
    data += (in -> Some(out))
  }
}

object MyServer extends App {
  val proj = new MyProject()
  Server.set_project(proj)
  Server.start(1337)
}
